import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
import { store } from './store'
import { ElAlert,ElAside,ElAutocomplete,ElAvatar,ElBacktop,ElBadge,ElBreadcrumb,ElBreadcrumbItem,ElButton,ElButtonGroup,ElCalendar,ElCard,ElCarousel,ElCarouselItem,ElCascader,ElCascaderPanel,ElCheckbox,ElCheckboxButton,ElCheckboxGroup,ElCol,ElCollapse,ElCollapseItem,ElCollapseTransition,ElColorPicker,ElContainer,ElDatePicker,ElDescriptions,ElDescriptionsItem,ElDialog,ElDivider,ElFooter,ElForm,ElFormItem,ElHeader,ElIcon,ElImage,ElInput,ElInputNumber,ElLink,ElMain,ElMenu,ElMenuItem, ElMenuItemGroup, ElOption, ElOptionGroup,ElPageHeader,ElPagination, ElPopconfirm,ElPopover,ElPopper, ElProgress,ElRadio, ElRadioButton,ElRadioGroup,ElRate,ElRow,ElScrollbar,ElSelect,ElSlider,ElStep,ElSteps,ElSubmenu,ElSwitch, ElTabPane,ElTable,ElTableColumn,ElTabs,ElTag,ElTimePicker,ElTimeSelect,ElTimeline,ElTimelineItem,ElTooltip,ElTransfer,ElTree,ElUpload,ElInfiniteScroll,ElLoading,ElMessage,ElMessageBox,ElNotification} from 'element-plus'


// import lang from 'element-plus/lib/locale/lang/zh-cn'
// import 'dayjs/locale/zh-cn'
// locale(lang)

//ElDrawer,ElDropdown,ElDropdownItem,ElDropdownMenu
//import * as Sentry from "@sentry/browser";//前端日志监控平台sentry使用
//import { Integrations } from "@sentry/tracing";





const components = [
  ElAlert,ElAside,ElAutocomplete,ElAvatar,ElBacktop,ElBadge,ElBreadcrumb,ElBreadcrumbItem,ElButton,ElButtonGroup,ElCalendar,ElCard,ElCarousel,ElCarouselItem,ElCascader,ElCascaderPanel,ElCheckbox,ElCheckboxButton,ElCheckboxGroup,ElCol,ElCollapse,ElCollapseItem,ElCollapseTransition,ElColorPicker,ElContainer,ElDatePicker,ElDescriptions,ElDescriptionsItem,ElDialog,ElDivider,ElFooter,ElForm,ElFormItem,ElHeader,ElIcon,ElImage,ElInput,ElInputNumber,ElLink,ElMain,ElMenu,ElMenuItem,ElMenuItemGroup,ElOption,ElOptionGroup,ElPageHeader,ElPagination,ElPopconfirm,ElPopover,ElPopper,ElProgress,ElRadio,ElRadioButton,ElRadioGroup,ElRate,ElRow,ElScrollbar,ElSelect,ElSlider,ElStep,ElSteps,ElSubmenu,ElSwitch,ElTabPane,ElTable,ElTableColumn,ElTabs,ElTag,ElTimePicker,ElTimeSelect,ElTimeline,ElTimelineItem,ElTooltip,ElTransfer,ElTree,ElUpload,
]
const plugins = [
  ElInfiniteScroll,
  ElLoading,
  ElMessage,
  ElMessageBox,
  ElNotification,
]


// 修改后的主题样式必须放在最后面
//import '../theme/index.css'

const app = createApp(App)
//ele-plus 引用
components.forEach(component => {
  app.component(component.name, component)
})
plugins.forEach(plugin => {
  app.use(plugin)
})

// 全局过滤器app.config.globalProperties.$filters 

const $filters= {
  prefix(url) {//默认路径，路径如果带http，就默认，不带就加入默认域名
    if (url && url.startsWith('http')) {
      return url
    } else {
      url = `https://www.shelinpin.com/${url}`
      return url
    }
  },
  resetImgUrl(imgObj, imgSrc, maxErrorNum) {  
    if (maxErrorNum > 0) { 
      imgObj.onerror = function() {  
        resetImgUrl(imgObj, imgSrc, maxErrorNum - 1) 
      }
      setTimeout(function() {  
        imgObj.src = imgSrc  
      }, 500)
    } else {  
      imgObj.onerror = null  
      imgObj.src = imgSrc
    }  
  }  
}
app.provide('$filters',$filters)
app.use(router)
app.use(store)
app.mount('#app')

    // Sentry.init({
    //   dsn: "https://f866b695d21d467ba523f1adf14e0a24@o584908.ingest.sentry.io/5737358",
    //   integrations: [new Integrations.BrowserTracing()],
    
    //   // Set tracesSampleRate to 1.0 to capture 100%
    //   // of transactions for performance monitoring.
    //   // We recommend adjusting this value in production
    //   tracesSampleRate: 1.0,
    // });

